<ui:composition template="/WEB-INF/templates/main-template.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
	
	<ui:define name="sidebar">
		<ui:include src="/WEB-INF/templates/public-sidebar.xhtml" />
	</ui:define>

	<ui:define name="content">
	<h:outputText value="Registered Vendors" styleClass="outputTextTitle"/>	
	
	<h:form>			
		
		
		<p:panel header="View/Delete Registered Vendors"> 

				<p:dataTable value="#{vendorRegistrationsBean.recruitmentVendors}" var="vendor" id="vendorList" paginator="true" rows="20">

					<p:column headerText="S.No">
						<h:outputText value="#{vendor.sNo}" />
					</p:column>
					<p:column headerText="Vendor Code">
						<h:outputText value="#{vendor.vendorCode}" />
					</p:column>
					<p:column headerText="Vendor Name">
						<h:outputText value="#{vendor.vendorName}" />
					</p:column>
					<p:column headerText="Vendor Email">
						<h:outputText value="#{vendor.vendorEmail}" />
					</p:column>
					<p:column headerText="Vendor contactNo">
						<h:outputText value="#{vendor.vendorContactNumber}" />
					</p:column>
					<p:column headerText="Created On">
						<h:outputText value="#{vendor.createDate}" >
							<f:convertDateTime pattern="dd-MMM-yyyy HH:mm a"/>
						</h:outputText>
					</p:column>
					<p:column headerText="Operation">
						<p:commandButton  value="View/Edit" oncomplete="vendorEditDialog.show()" 
							 update="@form" 
							actionListener="#{vendorRegistrationsBean.viewOrEditActionListener}">
							<f:attribute name="selectedVendor" value="#{vendor}" />
															
						</p:commandButton>
					</p:column> 

				</p:dataTable>
				
			
			</p:panel>
			
			
			<!-- Edit Dialog -->
			<p:dialog hideEffect="fade" showEffect="fade"
				header="View/Edit/Delete Recruitment Vendor #{vendorRegistrationsBean.selectedVendor.vendorCode} Details"
				id="vendorEditDialog" widgetVar="vendorEditDialog" resizable="false"
				modal="true">
				<h:panelGrid columns="3" cellpadding="10"
					style="border: 1px solid #d9d9d9; width: 100%">
				 
          
			           <h:outputLabel value="Vendor Reference Code" />
			           <h:outputLabel value=":" />
			           <p:inputText value="#{vendorRegistrationsBean.selectedVendor.vendorCode}" readonly="true" />
			          
			           <h:outputLabel value="Date of Registration" />
			           <h:outputLabel value=":" />
			           <p:inputText value="#{vendorRegistrationsBean.selectedVendor.createDate}" readonly="true"  >
			           			<f:convertDateTime pattern="dd-MMM-yyyy" />
					   </p:inputText>
			           
			           <h:outputLabel value="Registered By" />
			           <h:outputLabel value=":" />
			           <p:inputText value="#{vendorRegistrationsBean.selectedVendor.employee.firstName} #{vendorRegistrationsBean.selectedVendor.employee.lastName}" readonly="true" />
			          
			           <h:outputLabel value="Vendor Name " />
			           <h:outputLabel value=":" />
			           <p:inputText value="#{vendorRegistrationsBean.selectedVendor.vendorName}"  />
			           
			           <h:outputLabel value="Vendor E-Mail" />
			           <h:outputLabel value=":" />
			           <p:inputText value="#{vendorRegistrationsBean.selectedVendor.vendorEmail}"  />
			           
			           <h:outputLabel value="Vendor Contact Number" />
			           <h:outputLabel value=":" />
			           <p:inputMask value="#{vendorRegistrationsBean.selectedVendor.vendorContactNumber}"  mask="(999) 999-9999" />
			           
			           <h:outputLabel value="Vendor Contact Person" />
			           <h:outputLabel value=":" />
			           <p:inputText value="#{vendorRegistrationsBean.selectedVendor.vendorContactPerson}"   />
			           
			           <h:outputLabel value="Vendor Address" />
			           <h:outputLabel value=":" />
			           <p:inputTextarea value="#{vendorRegistrationsBean.selectedVendor.vendorAddress}"  autoResize="false" cols="17" />
			           
			           <h:outputLabel value="Remarks" />
			           <h:outputLabel value=":" />
			           <p:inputTextarea value="#{vendorRegistrationsBean.selectedVendor.remarks}"  autoResize="false" cols="17"/>			           
			     
								
				</h:panelGrid>	
				<h:panelGroup style="float:right;">
					<p:commandButton id="updateButton" value="Update" actionListener="#{vendorRegistrationsBean.confirmVendorRequest}" update="@form" />
					<p:commandButton id="deleteButton" value="Delete" actionListener="#{vendorRegistrationsBean.confirmVendorRequest}" update="@form" />
				</h:panelGroup>						
					 
									
				  
			</p:dialog>

			
			<p:growl id="growl" />
			
			<p:confirmDialog widgetVar="confirmationUpdate" id="confirmationUpdate" severity="alert" message="This will update your vendor information. Proceed?">
				<h:panelGroup style="text-align: right; float: right;">
					<p:commandButton value="Yes, Submit Now" actionListener="#{vendorRegistrationsBean.updateRecruitmentVendor}" update="@form" oncomplete="confirmationUpdate.hide()"/>
					<p:commandButton  value="Not Yet" onclick="confirmationUpdate.hide()" type="button" />
				</h:panelGroup>
	        </p:confirmDialog>
	        
	        <p:confirmDialog widgetVar="confirmationDelete" id="confirmationDelete" severity="alert" message="This will delete your vendor. Proceed?">
				<h:panelGroup style="text-align: right; float: right;">
					<p:commandButton value="Yes, Submit Now" action="#{vendorRegistrationsBean.deleteRecruitmentVendor}" update="@form" oncomplete="confirmationDelete.hide()"/>
					<p:commandButton  value="Not Yet" onclick="confirmationDelete.hide()" type="button" />
				</h:panelGroup>
	        </p:confirmDialog>
			
		

		</h:form>
	</ui:define>

</ui:composition>
